package com.tongji.housediy.controller.houseCMD
{
	import com.tongji.housediy.events.houseEvent.OpenHouseEvent;
	import com.tongji.housediy.model.HouseModel;
	import com.tongji.housediy.service.HouseService;
	
	import org.robotlegs.mvcs.Command;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/6/01
	 */ 
	public class OpenHouseCommand extends Command
	{
		[Inject]
		public var service:HouseService;
		
		[Inject]
		public var model:HouseModel;
		
		[Inject]
		public var event:OpenHouseEvent;
		
		override public function execute():void
		{
			switch(event.type)
			{
				case OpenHouseEvent.UPDATE_HOUSE_MODEL:
					model.updateHouseArray(event.houseArray);
					break;
				case OpenHouseEvent.GAT_ALL_HOUSES:
					service.getHouseArray(event.pageIndex, event.itemCount);
					break;
				case OpenHouseEvent.GET_HOUSE_BY_CANTAVIL:
					service.getHouseByCantavil(event.pageIndex, event.itemCount, event.cantavilID);
					break;	
				case OpenHouseEvent.GET_SAMPLE_HOUSE:
					service.getSampleHouseArr(event.pageIndex, event.itemCount);
					break;
				case OpenHouseEvent.UPDATE_SAMPLE_HOUSE:
					model.updateSampleHouse(event.houseArray);
					break;
			}
		}
	}
}